package com.shopping.dao.impl;


import com.shopping.dao.UserDao;
import com.shopping.model.User;
import com.shopping.utils.DBUtil;

public class UserDaoImpl extends DBUtil implements UserDao {
    public int addUser(User user){
        String sql ="insert into tbl_user values(default,?,?,?,?,?,?,?)";
        return super.executeUpdate(sql,user.getUser_name(),user.getUser_password(),user.getUser_email(),user.getUser_birthday(),user.getUser_hobbys(),user.getUser_sex(),user.getUser_address());

    }
    @Override
    public User login(String username,String password){
        String sql ="select user_id,user_name from tbl_user where user_name=? and user_password=?";
        return super.executeQueryOne(sql,User.class,username,password);
    }


    @Override
    public User getUserInfoById(Integer user_id) {
        String sql = "select * from tbl_user where user_id = ?";
        return super.executeQueryOne(sql,User.class,user_id);
    }
}
